Movie = require('../models/movie')
Category = require('../models/category')

# admin new page
exports.new = (req, res)->
  res.render 'category_admin',
    title: '后台分类录入页',
    category: {}

#admin post movie 从后台post过来的数据
exports.save = (req, res) ->
  _category = req.body.category
  category = new Category(_category)
  await category.save defer err, category
  console.log err if err
  res.redirect '/admin/category/list'

# catelist page
exports.list = (req, res)->
  await Category.fetch defer err, categories
  console.log err if err
  res.render 'categorylist',
    title: '分类列表页',
    categories: categories
